<template>
	清单
	<view>
		<tui-tabbar :current="currentTab" color="#AC9157" backgroundColor="#F8F4E1" :tabBar="tabBar"
			selectedColor="#AC9157" @click="tabbarSwitch">
		</tui-tabbar>
	</view>

</template>

<script>
	import {
		useCounterStore
	} from "../../../stores/counter.js";
	import {
		mapState,
		mapActions
	} from 'pinia';
	export default {
		data() {
			return {
				tabBar: [{
						pagePath: '/pages/index/list/index',
						text: '清单',
						iconPath: '/static/icon/qingdan.svg',
						selectedIconPath: '/static/icon/qingdan-s.png'
					},
					{
						pagePath: '/pages/index/plan/index',
						text: '计划',
						iconPath: '/static/icon/jihua.svg',
						selectedIconPath: '/static/icon/jihua-s.png'
					},
					{
						pagePath: '/pages/index/index',
						text: '选食材',
						iconPath: '/static/icon/cook.svg',
						hump: true,
						selectedIconPath: '/static/icon/cook-s.png'
					},
					{
						pagePath: '/pages/index/fridge/index',
						text: '冰箱',
						iconPath: '/static/icon/bingxiang.svg',
						selectedIconPath: '/static/icon/bingxiang-s.png'
					},
					{
						pagePath: '/pages/index/my/index',
						text: '我的',
						iconPath: '/static/icon/my.svg',
						selectedIconPath: '/static/icon/my-s.png',
						//num: 2,
						//isDot: true,
						//verify: true
					}
				],
				title: 'Hello'
			}
		},
		computed: {
			// 把pinia 的state映射到页面
			...mapState(useCounterStore, ["currentTab"])
			},
			onLoad() {
				uni.hideTabBar();
			},
			methods: {

				tabbarSwitch(e) {
					uni.switchTab({
						url: e.pagePath,
						success: () => { // 确保路由切换成功后再更新状态
							this.changeCurrentTab(e.index)
						}
					});
				},
				// 把pinia的方法映射到页面
				...mapActions(useCounterStore, ["changeCurrentTab"])
			}
		}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>